class Solution(object):
    def findMissingRanges(self, nums, lower, upper):
        """
        :type nums: List[int]
        :type lower: int
        :type upper: int
        :rtype: List[str]
        """
        out = []
        if not nums:
            if upper - lower == 0:
                out.append(str(upper))
            else:
                out.append(str(lower) + '->' + str(upper))
        for i in range(len(nums)):
            if i == 0:
                if nums[i] > lower:
                    if nums[i] - lower == 1:
                        out.append(str(lower))
                    else:
                        out.append(str(lower) + '->' + str(nums[i] - 1))
            if i == len(nums) - 1:
                if nums[i] < upper:
                    if upper - nums[i] == 1:
                        out.append(str(upper))
                    else:
                        out.append(str(nums[i] + 1) + '->' + str(upper))
            else:
                if nums[i] < nums[i + 1] - 1:
                    if nums[i + 1] - nums[i] == 2:
                        out.append(str(nums[i] + 1))
                    else:
                        out.append(str(nums[i] + 1) + '->' + str(nums[i + 1] - 1))
        return out


data = Solution()
nums = [2, 3, 50, 75, 99]
lower = 0
upper = 99
print(data.findMissingRanges(nums, lower, upper))
